<script src="__LAYUI__/layui.js"></script>
<link href="__LAYUI__/css/layui.css" rel="stylesheet"/>

<form class="layui-form layui-form-pane" action="/index/input/addEditor">
    <div class="layui-form-item" pane>
        <label class="layui-form-label">作者姓名</label>
        <div class="layui-input-block">
            <input type="text" name="authorName" required lay-verify="required" placeholder="请输入作者姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">工作单位</label>
        <div class="layui-input-block">
            <input type="text" name="authorObject" required lay-verify="required" placeholder="请输入工作单位" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

    <input type="hidden" name="author_level" value="{$author_level}">
    <input type="hidden" name="book_id" value="{$book_id}">
</form>
<script>
    layui.use(['form','jquery'],function () {
        var $ = layui.$;
        var form = layui.form;
        if({$author_level}<10){
            form.on('submit(demo1)', function(data){
                $.post('/index/input/addEditor',data.field,function (res) {
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 3000 //2秒关闭（如果不配置，默认是3秒）
                    });
                    if(res.code){
                        parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }
                })
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        }else{
            form.on('submit(demo1)', function(data){
                $.post('/index/input/addOthers',data.field,function (res) {
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 3000 //2秒关闭（如果不配置，默认是3秒）
                    });
                    if(res.code){
                        parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }
                })
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        }

    })
</script>